/**
 * @author gaopeng
 * @date 2019/12/17 10:37 下午
 */
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        originator.setState("初始状态");
        System.out.println("初始状态："+originator.getState());
        caretaker.setMemento(originator.createMemento());
        originator.setState("change1");
        caretaker.setMemento(originator.createMemento());
        originator.setState("change2");
        caretaker.setMemento(originator.createMemento());
        originator.setState("change3");
        caretaker.setMemento(originator.createMemento());
        System.out.println("改变后的状态："+originator.getState());

        for (String index : caretaker.getIndexs()) {
            System.out.println(index);
        }
        originator.restoreMemeto(caretaker.getMemento(2+""));
        System.out.println("恢复到2："+originator.getState());
    }
}
